package com.yiwei.ydd.fragment;

import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import com.yiwei.ydd.R;
import com.yiwei.ydd.adapter.MainIconAdapter;

/**
 * Created by xsooy-pc on 17-12-5.
 */

public class MainIconFragment extends BaseFragment {
    @BindView(R.id.list)
    RecyclerView list;
    Unbinder unbinder;
    private MainIconAdapter adapter;
    private List<String> listdata;

    @Override
    protected int setLayoutId() {
        return R.layout.fragment_main_icon;
    }

    public void setData(List<String> listdata) {
        this.listdata = listdata;
    }

    @Override
    protected void initView() {
        list.setLayoutManager(new GridLayoutManager(getContext(), 4));
        adapter = new MainIconAdapter(getContext());
        list.setAdapter(adapter);
        if (listdata != null && listdata.size() != 0) {
            adapter.update(listdata);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
